<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>塞纳皇宫-网站后台管理系统</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/static/admin/img/logo.png" type="image/x-icon">
    <link rel="shortcut icon" href="favicon.ico"> <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/static/admin/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="/static/admin/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <script src="/static/admin/js/city/jquery-1.11.3.min.js"></script>

    <!-- 全局/static/admin//static/admin//static/admin/js -->
    <script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="/static/admin/js/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <!-- <script src="/static/admin/js/plugins/validate/jquery.validate.min.js"></script>-->
    <!--<script src="/static/admin/js/plugins/validate/messages_zh.min.js"></script>-->
    <!--<script src="/static/admin/js/demo/form-validate-demo.js"></script>-->
    <script src="/static/admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>

    <!--script src="/static/admin/layer/layer.css"></script>-->
    <script src="/static/admin/layer/layer.js"></script>
    <style>

        .uploadbtn{position: absolute;padding: 5px 10px;background: #23b7e5;border-radius: 5px;color: #ffffff;z-index: 4}
        .uploadbtn:hover{background: #23b7e5;cursor: pointer;}
        .form-control{cursor: pointer;}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">

                    <div class="ibox-title">
                        <h5><a href="#" onclick="javascript:history.back(-1);">返回</a>编辑/添加</h5>
                    </div>
                </div>
            </div>
        </div>

                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="column-form" action="" method="post" onsubmit="return subForm()" enctype="multipart/form-data"  >
                            <input name="id" id="id" value="{if isset($data)}{$data.class_id}{/if}" type="hidden">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">分类名称：</label>
                                <div class="col-sm-2">
                                        <input id="title" name="name"  class="form-control" type="text" required=""  value="{if isset($data)}{$data.name}{/if}">
                                    <input type="hidden" id="inlineRadio1" value="1" name="show" checked="" {if isset($data) && $data.show ==1 }checked{/if}>
                                  <!--  <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入公司名称</span>-->
                                </div>
                            </div>






                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit" >提交</button>
                                </div>
                            </div>

                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <script src="/static/admin/js/city/area.js"></script>
    <script src="/static/admin/js/city/select.js"></script>

    <script  type="text/javascript">

        $(function(){
            $('.uploadbtn').click(function(){
                return $('#column_cover').click();
            })
        })


        function subForm(){
           var formobj = document.getElementById('column-form');
            var formData = new FormData(formobj);
            var id = $("#id").val();
            var column_cover = $("#column_cover").val();
            if(id =='' && column_cover ==''){
                layer.msg('请选择栏目封面');
                return false;
            }
            $.ajax({
                url:"/admin.php/aos/add_vclass",
                data:formData,
                type:"post",
                dataType:'json',
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
                success:function(res){
                    if(1==res.code) {
                        layer.msg(res.msg);
                        setTimeout(function(){
                            window.location.href="/admin.php/aos/vclass"
                        },1000)
                    }else{
                        layer.msg(res.msg);
                        return false;
                    }
                },
                error:function(){
                    layer.msg('系统错误');
                    return false;
                },

            });
            return false;
        }
        function uploadImg(file,showImg){
            if(!file.files[0]){
                return false;
            }

            if(!file.value.match(/.jpg|.png|.gif|.jpeg/i)){
                layer.msg('您选择的图片格式不正确，请重新选择');
                return false;
            }
            if(file.files[0].size > 1 * 1024 * 1024){
                layer.msg('您选择的图片不能大于1M，请重新选择！');
                return false;
            }
            var myPhoto = document.getElementById(showImg);
            var reader = new FileReader();
            reader.onload = function (e) {
                var dataURL = e.target.result;
                myPhoto.src = dataURL;
                myPhoto.style.display = 'block';
            };
            reader.readAsDataURL(file.files[0]);

        }
    </script>
</body>


</html>
